import java.awt.Point;
import java.util.Random;


public class KillAgent implements State 
{
	private FSMachine	m_fsm;
	private Point		m_desPos;
	private int myID;
	private int otherID;
	
	public KillAgent(FSMachine fsm)
	{
		m_fsm = fsm;		
	}
	
	public void Enter(int myID, int otherID)
	{
		//System.out.println("KillAgent - Enter");
		this.myID = myID;
		this.otherID = otherID;
	}
	
	public void Execute()
	{
		//System.out.println("KillAgent - Execute");
		System.out.println("The Killer just killed Agent "+otherID);
		boolean temp = Global.killInProgress;
                if(!Global.agents.get(otherID).isBusy){
		Global.killInProgress = true;
		temp = Global.killInProgress;
		Global.agents.get(otherID).setDeathCounter(Global.TURNS_UNTIL_DEATH);
		m_fsm.ChangeState(FSMachine.enumState.GUESS, myID, -1);}
                else{
                System.out.println("IMMA SNIPE DAT MOFO");
                Random r = new Random(); 
                int die=r.nextInt(5)+1;
                System.out.println("Shit was so effective I sent him a number "+die);
                Global.killInProgress = true;
		temp = Global.killInProgress;
		Global.agents.get(otherID).setDeathCounter(die+Global.TURNS_UNTIL_DEATH);
		m_fsm.ChangeState(FSMachine.enumState.GUESS, myID, -1);
                }
		// Pseudo-code
		// send an event to all agents with localization
	}
	
	public void Exit()
	{
		//System.out.println("KillAgent - Exit");
	}

	public void SetDesPos(Point desPos)
	{
		m_desPos = desPos;
	}
}
